﻿using EntityFramework.Entity.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YouTravel.DomainModels;

namespace Repositories.Configuration
{
    public class InsuranceMap : EntityConfigurationBase<Insurance>
    {
        public InsuranceMap()
        {
            this.Property(p => p.BranchName).HasMaxLength(50).IsRequired();
            this.Property(p => p.SpecialName).HasMaxLength(50).IsRequired();
            this.Property(p => p.Money).HasPrecision(18, 2);
            this.Property(p => p.Remark).HasMaxLength(200);
            this.Property(p => p.InsuranceNumber).HasMaxLength(100);
            this.Property(p => p.InsuranceUrl).HasMaxLength(200);

            this.HasRequired(p => p.Branch).WithMany().HasForeignKey(f => f.BranchId);
            this.HasRequired(p => p.Special).WithMany().HasForeignKey(f => f.SpecialId);
            this.HasRequired(p => p.Buyer).WithMany().HasForeignKey(f => f.BuyerId);
            this.HasMany(p => p.InsurancePersons).WithRequired(p => p.Insurance).HasForeignKey(p => p.InsuranceID);
        }
    }
}
